package cn.iocoder.yudao.module.brokerage.level.controller.admin;

import cn.iocoder.yudao.framework.business.basic.controller.ListController;
import cn.iocoder.yudao.framework.business.basic.controller.SimpleDetailController;
import cn.iocoder.yudao.framework.business.basic.controller.UpdateController;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.brokerage.level.pojo.vo.AdminBrokerageLevelQueryDTO;
import cn.iocoder.yudao.module.brokerage.level.pojo.vo.AdminBrokerageLevelSaveDTO;
import cn.iocoder.yudao.module.brokerage.level.pojo.vo.AdminBrokerageLevelVO;
import cn.iocoder.yudao.module.brokerage.level.service.AdminBrokerageLevelService;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;

@Tag(name = "管理后台 - 推广人员等级")
@RestController
@RequestMapping("/brokerage/level")
@Validated
public class BrokerageLevelController implements SimpleDetailController<AdminBrokerageLevelVO>, ListController<AdminBrokerageLevelVO, AdminBrokerageLevelQueryDTO>, UpdateController<AdminBrokerageLevelSaveDTO> {
    @Resource
    private AdminBrokerageLevelService adminBrokerageLevelService;

    @PreAuthorize("@ss.hasAnyRoles('super_admin', 'platform_admin', 'tenant_admin')")
    @Override
    public CommonResult<AdminBrokerageLevelVO> getDetail(Long id) {
        return success(adminBrokerageLevelService.getDetail(id));
    }

    @PreAuthorize("@ss.hasAnyRoles('super_admin', 'platform_admin', 'tenant_admin')")
    @Override
    public CommonResult<List<AdminBrokerageLevelVO>> getList(AdminBrokerageLevelQueryDTO param) {
        return success(adminBrokerageLevelService.getList(param));
    }

    @PreAuthorize("@ss.hasAnyRoles('super_admin', 'platform_admin', 'tenant_admin')")
    @Override
    public CommonResult<Boolean> update(AdminBrokerageLevelSaveDTO param) {
        return success(adminBrokerageLevelService.update(param));
    }

}